<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
import { queryFeedbackProcessed } from "../../../../api/index.js";
export default {
  data() {
    return {
      cdata: {
        category: [],
        lineData: [],
        barData: [],
        rateData: []
      }
    };
  },
  components: {
    Chart,
  },
  mounted() {
    this.getData();
  },
  methods: {
    // 根据自己的业务情况修改
    setData() {
      for (let i = 0; i < this.cdata.barData.length; i++) {
        let rate = this.cdata.barData[i] / this.cdata.lineData[i];
        this.cdata.rateData.push(rate.toFixed(2));
      }
    },
    getData() {
      let that = this;
      queryFeedbackProcessed().then(res => {
        that.cdata.category = []
        that.cdata.barData = []
        that.cdata.lineData = []
        res.data.forEach(index => {
          that.cdata.category.push(index.townName);
          that.cdata.barData.push(index.processedNum);
          let sum = index.noProcessedNum + index.processedNum
          that.cdata.lineData.push(sum);
        });
        this.setData()
      })
    }
  }
};
</script>

<style lang="scss" scoped>
</style>